<%@ Page language="c#" Inherits="FlashBack.Web.Search" CodeFile="Search.aspx.cs" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
  <HEAD>
    <meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
    <meta name="CODE_LANGUAGE" Content="C#">
    <meta name=vs_defaultClientScript content="JavaScript (ECMAScript)">
    <meta name=vs_targetSchema content="http://schemas.microsoft.com/intellisense/ie5">
  	<LINK REL="stylesheet" Type="text/css" HREF="FlashBack.css">
  	
  	<script language="javascript">
  	
 	function onBaseSearch()
  	{
  		baseSearch.style.display = "block";
  		advancedSearch.style.display = "none";
  		expertSearch.style.display = "none";
  		doSearch.onclick = DoBaseSearch;  		
  	}

  	function DoBaseSearch()
  	{
  		var adv = new Array();
  		
  		adv["{prop name=all}"] = srcstring.value;
  		DoSearch(adv);
  	}
  	
  	function onAdvancedSearch()
  	{
  		baseSearch.style.display = "none";
  		advancedSearch.style.display = "block";
  		expertSearch.style.display = "none";
  		doSearch.onclick = DoAdvancedSearch;
  	}
  	
  	function DoAdvancedSearch()
  	{
  		var adv = new Array();
  		
  		adv["@DocAuthor"] = Author.value;
  	    adv["@DocComments"] = Comments.value;
  	    adv["@DocKeywords"] = Keywords.value;
  	    adv["@DocSubject"] = Subject.value;
  	    adv["@DocTitle"] = Title.value;
  	   
  		DoSearch(adv);
  	}
  	
  	function onExpertSearch()
  	{
  		baseSearch.style.display = "none";
  		advancedSearch.style.display = "none";
  		expertSearch.style.display = "block";
  		expert.focus();
  		expert.select();
  		doSearch.onclick = DoExpertSearch;
  	}
  	
  	function DoExpertSearch(i_string)
  	{
		var adv = new Array();
  		
  		if(i_string == null)
  		{
  			adv[" "] = expert.value;
  		}
  		else
			adv[" "] = i_string;
			
  		DoSearch(adv);
  	}
  	  	
  	function AppendSrcToken(i_string,i_key,i_value)
  	{
  		if(i_value != "")
  		{
  			if(i_string != "")
  			{
  				i_key = " and " + i_key;
  			}
  			
  			return (i_key + " " + i_value);
  		}
  		
  		return "";
  	}
  	
  	function DoSearch(i_tokenArray)
  	{
  		var srcstring = "";
  		var a;
  		for( a in i_tokenArray)
  		{
  			srcstring += AppendSrcToken(srcstring,a,i_tokenArray[a]);
   		}
   		
   		if(srcstring == "")
   		{
   			alert("Please enter your query string and then press Search");
   			return;
   		}
  	
  		var q = "qu=" + escape(srcstring);
  		top.OnSearch(q);
 	}
  	 	
  	function onKeyPress()
  	{
  		if(event.keyCode == 13)
  		{
			doSearch.click();  			
  		}
  	}
  	
  	</script>
</HEAD>
	<BODY class="searchBody" onkeypress="onKeyPress()">
	<table class="searchBody" cellpadding="5" width="100%"><tr><td>
			<div id="baseSearch">
				 
				<div>Search For Pictures<br>
					<input title="This will search all properties of the picture for specified string" class="searchInput" id="srcstring" name="qu" type="text">
				</div>
				<div align="right" class="fakeAnchor" onclick="onAdvancedSearch()" ><br>Advanced Search &gt;</div>
			</div>
			
			<div id="advancedSearch" style="DISPLAY:none">
			
				<div>Author<br>
					<input class="searchInput" id="Author" type="text">
				</div>
				<div>Comments<br>
					<input class="searchInput" id="Comments" type="text">
				</div>
				<div>Keywords<br>
					<input class="searchInput" id="Keywords" type="text">
				</div>
				<div>Subject<br>
					<input class="searchInput" id="Subject" type="text">
				</div>
				<div>Title<br>
					<input class="searchInput" id="Title" type="text">
				</div>
				<div>Date Taken<br>
					<input class="searchInput" id="DateTaken" type="text">
				</div>
			
			<span class="fakeAnchor" onclick="onBaseSearch()" ><br>&lt; Base Search</span>&nbsp;&nbsp;
			<span class="fakeAnchor" onclick="onExpertSearch()" >Expert Search &gt;</span>
			</div>
			
			<div id="expertSearch" style="DISPLAY:none">
			
				<div>
					<textarea  class="searchInput" style="OVERFLOW: auto"  rows="15" id="expert" type="text">Enter advanced serach engine query here. Click on the help link below for syntax information.</textarea>
				</div>
				<div align="right"><a target="_blank" href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/indexsrv/html/ixuwebov_1qcn.asp">? Syntax Help</a></div>
				
			<div class="fakeAnchor" onclick="onAdvancedSearch()" ><br>&lt; Advanced Search</div>
			</div>
			
			<div align="right"><br><input id="doSearch" align="right" type="button" onclick="DoBaseSearch()" value="Search" style="FONT-SIZE: 12px; FONT-FAMILY: Verdana"></div>
			
	</td></tr>
	</table>
	
	<br>	
	<table cellspacing="1" align="center" class="popupTable" width="92%" cellpadding="3">
	<tr class="popupTableHeader" align="center"><td>Favorite Searches</td></tr>
	<tr class="popupTableBody"><td>
	
	<asp:DataList CssClass="popupTableBody" id="searchList" runat="server" RepeatLayout="Table" RepeatDirection="Vertical">
		<ItemTemplate>
			<div class="fakeAnchor" onclick="DoExpertSearch('<%# DataBinder.Eval(Container.DataItem, "Query")  %>')"><%# DataBinder.Eval(Container.DataItem, "Name") %></div>
		</ItemTemplate>
	</asp:DataList>
	</td></tr>
	</table>

	
	</BODY>
</HTML>
